package qx.hyj.petrescue.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import qx.hyj.petrescue.VO.Result;
import qx.hyj.petrescue.entity.Content;
import qx.hyj.petrescue.service.contentService;

@RestController
@RequestMapping("/Petrescue/content")
@Tag(name = "消息接口", description = "消息接口")
public class contentController extends BaseControllerImpl<Content,Integer> {

    @Autowired
    private contentService contentService;

    @Override
    public String getEntityName() {
        return "";
    }

    @GetMapping("/getcontent")
    @Operation(summary = "获取历史消息")
    public Result<?>  getcontent(@RequestParam Integer receiveId,@RequestParam boolean isRead,HttpServletRequest request){
        Integer userId = (Integer) request.getAttribute("id");
        return Result.success(contentService.getcontent(userId,receiveId,isRead));
    }

    @GetMapping("/getNewContentNumber")
    @Operation(summary = "获取新消息数量")
    public Result<?>  getNewContentNumber(HttpServletRequest request){
        Integer userId = (Integer) request.getAttribute("id");
        return Result.success(contentService.getNewContentNumber(userId));
    }

}
